﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using PeopleSource.Entities;
using PeopleSource.Utl;
using PeopleSource.Models;

namespace PeopleSource.Controllers
{
    public class ResumeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [GridAction]
        public ActionResult _SelectIndex(int? resumetype, int? jobtitle,string applyer)
        {
            return View(new GridModel((DQ.SearchResume(resumetype, jobtitle, applyer))));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _SaveAjaxEditing(int? id)
        {
            var item = CH.GetDataByID<Resume>(id);

            if (TryUpdateModel(item))
            {

                CH.Edit<Resume>(item);
            }
            return View(new GridModel((CH.GetAllDatas<Resume>())));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _InsertAjaxEditing(int? id)
        {
            var item = new Resume();

            if (TryUpdateModel(item))
            {

                CH.Create<Resume>(item);
            }
            return View(new GridModel((CH.GetAllDatas<Resume>())));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _DeleteAjaxEditing(int? id)
        {
            CH.Delete<Resume>(id);
            return View(new GridModel((CH.GetAllDatas<Resume>())));
        }
    }
}
